package com.shop.www.daoX;

import com.shop.www.po.user;

import java.util.List;

import static oracle.jrockit.jfr.events.Bits.intValue;

public class UserDAOImpl extends BasicDao implements UserDAO{

    @Override
    public List userlist(Integer pageNo) {//获取全部人物的信息
       return super.querymany("select ID,name,age from t14 limit ?,5", user.class,(pageNo-1)*5);

    }

    @Override
    public user getusermess(Integer id) {//根据人物编号获取消息
        user role = (user) super.querysingle("select ID,name,age from t14 Where ID =?", user.class, id);
        return role;
    }

    @Override
    public void updateuser(user role) {//修改单个人物的信息
        String sql = ("UPDATE t14  set `name` =?,`age`=? where id=?;");
        super.update(sql,role.getName(),role.getAge(),role.getId());
    }

    @Override
    public void deleteuser(Integer id) {//根据ID删除人物
        String sql = ("DELETE FROM t14 WHERE id = ?");
        super.update(sql,id);

    }

    @Override
    public void adduser(user role) {//添加新人物
        String sql = ("INSERT INTO t14 VALUES ( 0,?,?)");
        super.update(sql,role.getName(),role.getAge());
    }

    @Override
    public int userCount() {
        Object obj = super.queryScalar("select count(*) from t14");
        long longstr =  (Long) obj;
        Integer count = intValue(longstr);
        return count;

    }

    }



